<!DOCTYPE html>
<html>
<head>
  <title>CNAD/P/T赛事数据处理应用</title>
  <meta charset="utf-8">
  <title>score manage</title>
  <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
  <meta http-equiv="Pragma" content="no-cache" />
  <meta http-equiv="Expires" content="0" />

  <link rel="stylesheet" href="/css/common.css?t=202208091450" type="text/css">

  <script src="/js/vue/vue.js"></script>

  <link rel="stylesheet" href="/js/elementui/index.css">
  <script src="/js/elementui/index.js"></script>

  <script src="/js/theme/pptx/libs/jquery.min.js"></script>
  <script src="/js/theme/xlsx.full.min.js"></script>

  <script src="/js/common.js?t=20250804"></script>

  <script src="/js/cert/setting.js?t=20250804"></script>
  <script src="/js/base.data.info.js?t=20250804"></script>
  <script src="/js/excel.data.handler.js?t=20250804"></script>

  <script src="js/data.info.js?t=20250804"></script>
  <script src="js/excel.data.js?t=20250804"></script>

  <style>

      #div-step1 input {

          font-size: 20px;
      }
      .div-upload {text-align: center}
      .div-upload > div {margin-bottom: 10px;}


      .my-upload input {
          position: absolute;
          left: 0px;
          top: 0px;
          width: 100%;
          height: 100%;
          opacity: 0;
      }
      .my-upload {position: relative}


      .div-step3 {
          margin-top: 20px;
          text-align: center;
          zoom: 1.1;
      }
      .div-step3 > div {margin-bottom: 20px;}
      .div-step3 > div:last-child{ zoom: 0.9}
  </style>
  
</head>
<body>
<div id="app" style="padding-top: 20px;">
  <div style="text-align: center;">====================================</div>  
  <div id="title" style="text-align: center;"> CNAD/P/T 赛事数据处理应用</div>
  <div id="first" style="text-align: center;"> {{ firstTitle }}</div>  
  <div style="text-align: center;">====================================</div>  
  <el-row style="margin-top: 20px;"  v-if="html.step==='1' || html.step=='2.5'">
    <el-col :span="24" style="text-align: center;zoom: 1.3">
      <span>加载中.....</span>
    </el-col>
  </el-row>
  <el-row style="margin-top: 20px;"  v-else-if="html.step=='2'">

    <el-col :span="24" class="div-upload" >
      <div>
        <el-button type="primary" class="my-upload" size="mini">
          <input type="file" v-model="dataValue" id="file-uploader" @change="uploadData" />
          <span>选择文件</span>
        </el-button>
        <span style="font-size:12px;margin-left: 20px">赛事excel数据上传</span>
      </div>
      <div>
        <el-checkbox v-model="isReadStudentScore">直接读取个人总分数</el-checkbox>
      </div>
      <div>
        <el-checkbox v-model="isReadTeamScore">直接读取团队总分数</el-checkbox>
      </div>
      <div style="margin-top: 100px;text-align: center">
        <el-button @click="history.go(-1)" type="primary" plain>返回</el-button>
      </div>
    </el-col>
    <el-col :span="12" :offset="6" style="padding-top: 20px;" v-show="errorList.length>0">
      <b>错误列表</b>
      <el-table :data="errorList">
        <el-table-column prop="name" label="sheet" width="170"></el-table-column>
        <el-table-column prop="pos" label="行数" width="100"></el-table-column>
        <el-table-column prop="error" label="错误信息"></el-table-column>
      </el-table>
    </el-col>
  </el-row>

  <el-row class="div-step3" v-else-if="html.step=='3'" >

    <div>
      <el-button type="primary" @click="open('setting')">奖项设置</el-button>
      <!-- <el-button type="primary" @click="open('ppt')">颁奖ppt</el-button>       -->
      <el-button type="primary" @click="open('cert')">获奖信息</el-button>
      <el-button type="primary" @click="open('query')">统计分析</el-button>
    </div>

    <div style="margin-top: 80px"><el-button type="primary" plain @click="html.step=2" >返回</el-button></div>
  </el-row>
</div>

</body>
<script>
  new Vue({
    el: '#app',
    data: {
      html:{
        step:DataUtils.get("step") || 1,
        showText:"展开",
        showTextStatus:false,
        loading:false,
        pages:{
          "ppt":"detail_ppt.html",
          "cert":"detail_cert.html",
          "report":"detail_report.html",
          "setting":"detail_setting.html",
          "query":"detail_query.html",
        }
      },
      firstTitle:"",
      errorList:[],
      dataValue:"",
      excelDataHandler:null,
      isReadStudentScore:false,
      isReadTeamScore:false
    },
    created: function () {      
      let setting = _Setting.loadSetting();
      // $("#title").text(setting.getValue("sys.app.copyright"));
      let first = DataUtils.get("first");
      this.firstTitle = first == "china" ? "中国站":"初级站";
      if (this.html.step == 1){
        DataUtils.set("step", 2);
        this.html.step = '2';
      }


    },
    methods: {

      uploadData(e){
        let options = {isReadStudentScore:this.isReadStudentScore,isReadTeamScore:this.isReadTeamScore };
        let _this = this;
        let files = e.currentTarget.files;
        _this.html.step = '2.5';
        this.errorList = [];
        let reader = new FileReader();
        reader.onload = function (e) {
          try{
            _this.dataValue = "";
            let [result,errors] = ExcelData.getExcelData(e.target.result, options);
            if (errors && errors.length > 0){
              _this.errorList = errors;
              _this.html.step = '2';
              return;
            }
            // DataUtils.set("excelData", result);
            let r = ExcelUtils.setItem(result);
            if (r != "ok"){
              _this.$message.error("excel数据上传失败");
            }

            _this.html.step = '3';
            DataUtils.set("step", '3');
          }finally {
            _this.html.loading = false;
          }

        };
        reader.readAsBinaryString(files[0]);

      },
      selectArea(area){
        DataUtils.set("area", area);
        this.html.step=4;
        DataUtils.set("step", '4');
      },
      open(page){
        window.location.href = this.html.pages[page]+'?t='+getUrlParam("t");
      }
    }
  })
</script>
</html>